# for GDC

CC = gdc

SOURCES=boot.d actor.d character.d clickable.d config.d hell2.d keypad.d opengl.d openglu.d state.d vector.d $(wildcard SDL/*.d)
OBJS=$(SOURCES:.d=.o)
TARGET=hogeframe

ifeq (${shell uname}, Darwin)
	CFLAGS_ENV=-fversion=Darwin
	LDFLAGS_ENV=-dylib_file /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib -L/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries -lGL -lGLU
else
ifeq (${shell uname | sed s/_.*//}, MINGW32)
	LDFLAGS_ENV=-lopengl32 -lglu32
else
	LDFLAGS_ENV=-lGL -lGLU
endif
endif

CFLAGS=-g -Wall -fversion=GDC -ISDL `sdl-config --cflags` $(CFLAGS_ENV)
LDFLAGS=-lSDL_mixer `sdl-config --libs` $(LDFLAGS_ENV)


all: $(TARGET)

$(OBJS): %o: %d
	$(CC) $(CFLAGS) -c $< -o $@

$(TARGET): $(OBJS)
	$(CC) -o $@ $(OBJS) $(LDFLAGS)

actor.o: actor.d vector.d

boot.o: boot.d hell2.d state.d

clickable.o: clickable.d vector.d hell2.d

config.o: config.d

hell2.o: hell2.d opengl.d openglu.d

keypad.o: keypad.d hell2.d

state.o: state.d hell2.d vector.d keypad.d actor.d clickable.d gamecore.d

vector.o: vector.d

opengl.o: opengl.d

openglu.o: openglu.d opengl.d

clean:
	@for file in $(OBJS) $(TARGET) $(TARGET).exe; \
	 do \
	   if test -f "$$file"; then \
	     rm -f "$$file"; \
	   fi \
	 done
